{include file="public/header" /}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.css"}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.js"}
<style>
    #des, #des input {
        width: 40px;
        text-align: center;
    }

    #id {
        width: 78px;
    }

    .bs-checkbox {
        width: 36px;
        height: 40px
    }

    .fixed-table-toolbar .columns, .fixed-table-toolbar .search {
        margin-left: 0px;
        margin-top: 0px
    }

    #title span {
        float: right;
        margin-left: 3.333px;
    }

    .search {
        margin-bottom: 0px !important;
    }

    .asdlkjasd {
        background: #1ab394;
        color: #fff
    }

</style>
<body class="gray-bg">
<div class="wrapper wrapper-content {:config('adminClass.main')}">
    <div class="ibox float-e-margins">
        {include file="public/tophead"}
        {include file="public/top" /}
        <div class="ibox-content">
            {include file="public/topsection"}
            <div class="row row-lg">
                <div class="col-sm-12">
                    <div class="fixed-table-toolbar">
                        <a class="btn btn-default btn-outline {eq name='state' value='0'}asdlkjasd{/eq}" href="{:url('feedback',['state'=>0])}">待处理</a>
                        <a class="btn btn-default btn-outline {eq name='state' value='1'}asdlkjasd{/eq}" href="{:url('feedback',['state'=>1])}">已处理</a>
                    </div>
                    <div class="example">
                        <form class="form-horizontal" method="post">
                            <table data-toggle="table">
                                <thead>
                                <tr>
                                     <th class="bs-checkbox"><input type="checkbox" id="delidAll"></th>
                                    <th data-align="center">ID</th>
                                    <th data-align="center">用户</th>
                                    <th>描述</th>
                                    <th>回复</th>
                                    <th data-align="center">时间</th>
                                    <th data-align="center">状态</th>
                                    <th data-align="center">管理</th>
                                </tr>
                                </thead>
                                <tbody id="form">
                                {volist name="data" id="v"}
                                <tr id="id{$v.id}" class="class">
                                   <td id="delid" ><input name="delAll[]" type="checkbox" value="{$v.id}"></td>
                                    <td id="id">{$v.id}</td>
                                    <td><a onclick="member('{$v.user_id}')" style="color:#40BCF7">{$v.name}</a></td>
                                    <td id="title">
                                        <a onclick="watch('{$v.id}')">
                                            {:_substr($v['content'], 40)}
                                            {if condition="$v.images"}
                                            <span class="label label-primary">图</span>
                                            {/if}
                                        </a>
                                    </td>
                                    <td>{:_substr($v['reply'], 40)}</td>
                                    <td>
                                        <span {php}if(date('Ymd')==date('Ymd',strtotime($v['addtime'])))echo 'style="color: #ed5565"';{/php}>{:date('Y-m-d H:i', strtotime($v.addtime))}</span>
                                    </td>
                                    <td>{eq name='$v.state' value='0'}<span class="btn btn-default btn-xs">待处理</span>{else /}<span class="btn btn-primary btn-xs">已处理</span>{/eq}</td>
                                    <td>
                                        <div class="btn-group">
                                            <div data-toggle="dropdown" class="btn btn-primary btn-xs dropdown-toggle">操作 <span class="caret"></span>
                                            </div>
                                            <ul class="dropdown-menu">
                                                {switch name="$v.state"}
                                                    {case value="0"}
                                                        <li><a onClick="shenhe({$v.id})">处理</a></li>
                                                        <li class="divider"></li>
                                                    {/case}
                                                {/switch}
                                                <li><a onclick="del('{$v.id}')" style="color:red">删除</a>
                                                </li>
                                            </ul>
                                        </div>
                                    </td>
                                </tr>
                                {/volist}
                                </tbody>
                            </table>
                        </form>
                    </div>
                </div>
            </div>
            <hr>
            <div class="row row-lg">
                <div class="col-sm-6">
                      <div  class="btn btn-outline btn-default" onclick="alla()">
                        批量处理
                    </div>
                </div>
                <div class="col-sm-12 pages">{$page}</div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript">
$(document).ready(function(){

    
    $('#delidAll').click(function(){
        $('input[type=checkbox]').each(function(){
            var self=$(this);
            if(!self.prop('checked')){
                self.prop('checked',true);
            }else{
                self.prop('checked',false);
            }
        });
    })
});
    function del(id){
        swal_del(id,"{:url('feedbackDel')}")
    }

    function watch(id) {
        layui.use('layer', function(){
            var layer = layui.layer;
            layer.open({
                title :'预览',
                area: ['100%', '100%'],
                type: 2,
                content: '{:url("feedbackwatch")}?id='+id
            });
        });
    }

    function shenhe(id)
    {
        layer.prompt({title: '回复', formType: 2}, function(text, index){
            var reply = text;

            ajaxFun("post","{:url('feedbackadd')}",{id:id,reply:reply},'json',function(ret){
                if(ret){
                    if(ret.ret){
                        layer.msg(ret.ret)
                        window.location.reload()
                    }else{
                        layer.msg(ret.err)
                    }
                }else{
                    swal_msg("错误",ret,"error");
                }
            })
        });
    }

    function member(id)
    {
        layui.use('layer', function(){
            var layer = layui.layer;
            layer.open({
                title :'预览',
                area: ['100%', '100%'],
                type: 2,
                content: '{:url("member/index")}?search=id&name='+id
            });
        });
    }
function alla(){
    var all=$(".form-horizontal").serialize();
    var alls=$(".form-horizontal").serializeArray();
   //console.log(JSON.stringify(alls))

    ajaxFun("post",'{:url('question/feedbackAll')}',all,'json',function(ret){
        if(ret){
            swal_msg('操作成功')
        }
    })
}
 
</script>
 